<?php
	define('ROOT_PATH', dirname(__FILE__));

	$file = $_GET['path'];
	$src = preg_replace('%^(.*?/?)\d+x\d+/(.*)$%', '$1$2', $file);
	if(!is_file($src)){
		exit;
	}
	
	//分离出规格
	$width = preg_replace('%^.*?/?(\d+)x(\d+)/.*$%', '$1', $file);
	$height = preg_replace('%^.*?/?(\d+)x(\d+)/.*$%', '$2', $file);
	
	//原始图片路径
	$img_path = $src;
	//		echo $img_path;exit;
	//压缩图片路径
	$des_path = ROOT_PATH . '/' . $file;
	
	require_once ROOT_PATH . '/protected/components/ImageHandler.php';
	//切割
	$handle = new ImageHandler();
	$handle->setSrcImg(ROOT_PATH. '/' . $img_path);
	$handle->setDstImg($des_path);
	$handle->createImg($width, $height);
	if(!file_exists($des_path)){
		//文件创建失败
		exit;
	}
	header( "Content-type: image/jpeg");
	$size = filesize($des_path);
	$picture_data = fread(fopen($des_path, "r"), $size);
	echo $picture_data;
	exit;